//
//  GJNetWork.h
//  xmgjAppFront
//
//  Created by Zeki on 2020/7/8.
//  Copyright © 2020 guojutech. All rights reserved.
//网络请求类

#import <Foundation/Foundation.h>

#import "AFHTTPSessionManager.h"
#import "GJNetworkConfig.h"
#import "GJResult.h"


NS_ASSUME_NONNULL_BEGIN

typedef void(^Success)(GJResponse *response);
typedef void(^Failure)(NSString *errorMessage);
typedef void(^Complete)(GJResult *result);

@interface GJNetWork : AFHTTPSessionManager
@property (copy, nonatomic) NSString *networkType; // 网络状态
+ (instancetype)sharedInstance;
+ (AFSecurityPolicy *)securityPolicy;

- (NSURLSessionDataTask *)postWithURL:(NSString *)url params:(NSDictionary *)params success:(Success)success failure:(Failure)failure;
- (NSURLSessionDataTask *)getWithURL:(NSString *)url params:(NSDictionary *)params success:(Success)success failure:(Failure)failure;

/**
 *  自定义POST方法
 *
 *  @param retryCount 重试请求次数
 */
- (NSURLSessionDataTask *)POST:(NSString *)URLString
                    retryCount:(NSInteger)retryCount
                    parameters:(id)parameters
                      progress:(void (^)(NSProgress *uploadProgress))uploadProgress
                       success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
                       failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure;
@end

NS_ASSUME_NONNULL_END
